import Vue from 'vue'
import localType from '@/utils/type-collector.json'
const state = {
  typeCollector: {}
}

const mutations = {
  SET_TYPE_COLLECTOR: (state, value) => {
    state.typeCollector = value
  }
}

const actions = {
  getAllType ({ commit, state }, roles) {
    return new Promise(resolve => {
      Vue.prototype
        .$POST('sot-admin-api/vip/vip-level/queryForList') // 会员等级
        .then(res => {
          if (res.data) {
            let resData = res.data
            let o = []
            o = resData.map(_ => {
              return { label: _.levelName, value: _.id }
            })
            localType.data['level'] = o
          }
          // localType.data['level'] = [{ "label": "白银", "value": 1 }]
          commit('SET_TYPE_COLLECTOR', localType.data)
        })
    })
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
